function getCurrentPlayerRank(playerName, allScores) {
    try {
        // Sort scores to ensure correct ranking
        const sortedScores = [...allScores].sort((a, b) => {
            if (b.objectData.score !== a.objectData.score) {
                return b.objectData.score - a.objectData.score;
            }
            return new Date(b.objectData.timestamp) - new Date(a.objectData.timestamp);
        });

        // Find player's rank
        const playerIndex = sortedScores.findIndex(
            score => score.objectData.playerName.toLowerCase() === playerName.toLowerCase()
        );

        return playerIndex === -1 ? null : {
            ...sortedScores[playerIndex],
            position: playerIndex + 1
        };
    } catch (error) {
        reportError(error);
        return null;
    }
}
